import Vue from 'vue'
import Router from 'vue-router'

import About from "../views/About";
import Home from "../views/Home";
import News from "../views/News";
import Message from "../views/Message";
import MessageDetail from "../views/MessageDetail";

/*全局注入插件*/
Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/about',
      component: About
    },
    {
      path:'/home',
      component:Home,
      children:[
        {path:'/home/news',component:News}, /*path左边的/表示根路由*/
        {
          path:'message',
          component:Message,
          children:[
            {
              /*也可以通过query进行传参 ?id=... 那样的话这里不用写值*/
              // path:'detail', 对应的 detail/${message.id} 变为detail?id=${message.id}
              /*: 进行占位，通过param进行传参*/
              path:'detail/:id',
              component:MessageDetail
            }
          ]
        }, /*可以这样写*/
        {path:'',component:News} /*可以这样写*/
      ]
    },
    {
      path:'/',
      component:About
    }
  ]
})
